from v3.Pipeline import Pipeline
from v3.MySqlConnector import MySqlHelper


class MySqlPipeline(Pipeline):
    def __init__(self):
        self.helper = MySqlHelper()

    def process(self, page):
        result_list = page.get_result()
        self.helper.insert_many(sql="insert into sina.comments(userid, username, create_time, text) values (%s, %s, %s, %s);",
                           param_list=result_list)